(function(global, $){
	// 全局对象
	var Wilson = global.Wilson || {};
	
	// sku页面图片设定
	Wilson.SkuImgInit = new Class({
		initialize: function(elementid) {
			this.element = $('Moveable') || null;
			this.bigimg = $('BigImg') || null;
			this.linkel = $('ZoomIt') || null;
			this.zoomer = null;
			if (this.element && this.bigimg && this.linkel) {
				this.zoomer = new ZoomIt({'elems': '.ZoomIt'});
				this.element.getElements('a').each(function(el, index){
					el.addEvent('click', function(e){
						e.stop();
						this.zoomer.destroy();
						this.linkel.setProperty('href', el.getProperty('rev'));
						this.bigimg.setProperty('src', el.getProperty('rel'));
						this.element.getElements('a').removeClass('ImgCurr');
						this.zoomer = new ZoomIt({'elems': '.ZoomIt'});
						el.addClass('ImgCurr');
					}.bind(this));
				}.bind(this));
			}
		},
		destroy: function(){
			this.element.getElements('a').removeEvents(); 
			if (this.zoomer) {
				this.zoomer.destroy();
			}
			this.linkel.setProperty('href', 'javascript:void(0);');
		}
	});
	
	// sku页面TAB设定
	Wilson.SkuTabInit = new Class({
		initialize: function() {
			this.infos = $$('.ProdInfo') || null;
			if (this.infos) {
				this.infos.each(function(el, index){
					var tabs = el.getElement('.InfoTab');
					var contents = el.getElement('.InfoContent');
					if (tabs && contents) {
						var tabLis = tabs.getElements('li');
						var contentLis = contents.getElements('li');
						tabLis.each(function(el2, index2){
							el2.addEvent('click', function(e){
								e.stop();
								tabLis.removeClass('InfoSel');
								contentLis.removeClass('InfoSel');
								el2.addClass('InfoSel');
								if (contentLis[index2]) {
									contentLis[index2].addClass('InfoSel');
								}
							}.bind(this));
						}.bind(this));
					}
				}.bind(this));
			}
		}
	});
	
	global.Wilson = Wilson;
})(this, document.id || $);
